import React, { Component } from 'react';
import { addNavigationHelpers } from 'react-navigation';
import { AppNavigator } from './app.router';
import { connect } from 'react-redux';
import SplashScreen from 'react-native-splash-screen'
class AppC extends Component {
    constructor(){
        super();
        this.state={};
        this.isInit=true;
    }
    componentWillReceiveProps(nextProps){
        this.isInit==true?(SplashScreen.hide(),this.isInit=false):"";
        nextProps?this.setState({params:nextProps.nav.routes[0].params}):"";
    }
    render() {
        return(
        <AppNavigator screenProps={this.state.params} navigation={addNavigationHelpers({
            dispatch: this.props.dispatch,
            state: this.props.nav,
        })} />
        );
    }
}

mapStateToProps = (store) => ({
    nav: store.navReducer,
});

export const AppState = connect(mapStateToProps)(AppC);